<!-- <! [CDATA [

	/*
	----------------------------------------------------
	| Games On The Fly - copyright 2008, Murangura.com |
	| Code Written By Moraru Ionut                     |
	| Compile Date: 14.04.2008                         |
	| functions.js                               |
	----------------------------------------------------
	*/

var busy = false;
var position = 0;

function obiect_ajax() {
// Mozilla/Safari
    if (window.XMLHttpRequest) {
        obiect = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        obiect = new ActiveXObject("Microsoft.XMLHTTP");
    }
	return obiect;
}

function searchGames(){
	if (!busy) {
		busy = true;
		loading(true);
		var gamesArray = obiect_ajax();
		var value = document.getElementById('search').value;
		var url = "http://murangura.com/librarie/search_jocuri.php";
		var params = "value=" + value + "&position=" + position + "&html=air";
		
		gamesArray.open("POST", url, true);
		
		gamesArray.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		gamesArray.setRequestHeader("Content-length", params.length);
		gamesArray.setRequestHeader("Connection", "close");
		
		gamesArray.onreadystatechange = function(){
			if (gamesArray.readyState == 4 && gamesArray.status == 200) {
				document.getElementById('gamesContainer').innerHTML = '<ul>' + gamesArray.responseText + '</ul>';
				busy = false;
				loading(false);
			}
		}
		gamesArray.send(params);
	}
	document.getElementById('search').focus();
}

function navigate(direction) {
	var pas = 12;
	switch(direction) {
		case '+':
			position += pas;
			searchGames();
		break;
		case '-':
			position -= pas;
				if (position<0) position = 0;
			searchGames();
		break;
		default:
			return 0;
		break;
	}
}

function loading(on) {
	if (on) {
		document.getElementById("loading").style.display = 'block';
	}	else   {
		document.getElementById("loading").style.display = 'none';
	}
}

// ]]> -->